package dao.impl;

import dao.BaseDao;
import dao.UserDao;
import entity.User;

import java.sql.ResultSet;
import java.sql.SQLException;

public class UserDaoImpl extends BaseDao implements UserDao {

    @Override
    public User verifyUser(String name, String pwd) {
        String sql = "SELECT * FROM jsh_user WHERE login_name = ? AND `password` = ?";
        ResultSet rs = executeQuery(sql,name,pwd);
        try {
            if(rs.next()){
                User user = new User();
                user.setUsername(rs.getString(1));
                user.setLoginName(rs.getString(2));
                user.setPassword(rs.getString(3));
                user.setPhoneNum(rs.getString(4));
                user.setIsmanager(rs.getInt(5));
                user.setStatus(rs.getInt(6));
                return user;
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }
}
